<?php

class WallModel extends Model {
    public $tableName = "wall";

    protected $belongs_to = array('bm_auth' , 'bm_wall' , 'bm_photo');
    protected $has_many = array('hm_wall');

    public function __construct($query = null) {
        parent::__construct($query);
    }

    public function getPoster() {
        return Model::factory('auth' , $this->poster_id);
    }

    public function getParentWall() {
        $wall = Model::factoryQuery('wall', "SELECT * FROM `wall` WHERE `id` = ".$this->id.";");
        if ($wall->loaded())
            return $wall;
        else
            return null;
    }

    public function getChildWalls() {
        $walls = Model::loadRowsFromQuery("SELECT * FROM `wall` WHERE `wall_id` = ".$this->id.";", 'WallModel');
        return $walls;
    }
	
}

?>